---
title: Weaviate Agent Knowledge
sidebarTitle: Weaviate
---

Follow steps mentioned in [Weaviate setup guide](https://weaviate.io/developers/weaviate/quickstart) to setup Weaviate.

## Setup

Install weaviate packages

```shell
pip install weaviate-client
```

Run weaviate

```shell
docker run -d \
  -p 8080:8080 \
  -p 50051:50051 \
  --name weaviate \
  cr.weaviate.io/semitechnologies/weaviate:1.28.4 
```

or 

```shell
./cookbook/scripts/run_weaviate.sh
```

## Example

```python agent_with_knowledge.py
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.search import SearchType
from agno.vectordb.weaviate import Distance, VectorIndex, Weaviate

vector_db = Weaviate(
    collection="recipes",
    search_type=SearchType.hybrid,
    vector_index=VectorIndex.HNSW,
    distance=Distance.COSINE,
    local=True,  # Set to False if using Weaviate Cloud and True if using local instance
)
# Create knowledge base
knowledge_base = Knowledge(
    vector_db=vector_db,
)

# Create and use the agent
agent = Agent(
    knowledge=knowledge_base,
    search_knowledge=True,
)

if __name__ == "__main__":
    knowledge_base.add_content(
        url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"
    )

    agent.print_response("How to make Thai curry?", markdown=True)
```

<Card title="Async Support ⚡">
  <div className="mt-2">
    <p>
      Weaviate also supports asynchronous operations, enabling concurrency and leading to better performance.
    </p>
    
    ```python async_weaviate_db.py
    import asyncio

    from agno.agent import Agent
    from agno.knowledge.knowledge import Knowledge
    from agno.vectordb.search import SearchType
    from agno.vectordb.weaviate import Distance, VectorIndex, Weaviate

    vector_db = Weaviate(
        collection="recipes_async",
        search_type=SearchType.hybrid,
        vector_index=VectorIndex.HNSW,
        distance=Distance.COSINE,
        local=True,  # Set to False if using Weaviate Cloud and True if using local instance
    )
    
    # Create knowledge base
    knowledge_base = Knowledge(
        vector_db=vector_db,
    )

    agent = Agent(
        knowledge=knowledge_base,
        search_knowledge=True,
    )

    if __name__ == "__main__":
        # Load knowledge base asynchronously
        asyncio.run(knowledge_base.add_content_async(
                url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"
            )
        )

        # Create and use the agent asynchronously
        asyncio.run(agent.aprint_response("How to make Tom Kha Gai", markdown=True))
    ```
    
    <Tip className="mt-4">
      Weaviate's async capabilities leverage <code>WeaviateAsyncClient</code> to provide non-blocking vector operations. This is particularly valuable for applications requiring high concurrency and throughput.
    </Tip>
  </div>
</Card>

## Weaviate Params

<Snippet file="vectordb_weaviate_params.mdx" />

## Developer Resources

- View [Cookbook (Sync)](https://github.com/agno-agi/agno/blob/main/cookbook/knowledge/vector_db/weaviate_db/weaviate_db.py)
- View [Cookbook (Async)](https://github.com/agno-agi/agno/blob/main/cookbook/knowledge/vector_db/weaviate_db/async_weaviate_db.py)